function bump(box, show) {
	var boxInfo = box.getBoundingClientRect();
	var showInfo = show.getBoundingClientRect();
	var t1 = boxInfo.top;
	l1 = boxInfo.left;
	r1 = boxInfo.right;
	b1 = boxInfo.bottom;

	var t2 = showInfo.top;
	l2 = showInfo.left;
	r2 = showInfo.right;
	b2 = showInfo.bottom;

	if(r1 < l2 || l1 > r2 || t1 > b2 || b1 < t2) {
		console.log("未出现碰撞");
		return false;
	} else {
		console.log("发出警告:已碰撞！");
		return true;
	}
}
var startBth = document.querySelector(".botton");
startBth.addEventListener("click",()=>{
	startBth.parentNode.style.left = "-100%";
});
startBth.parentNode.style.left = "-100%";
var web = document.querySelector(".web");

var overall = document.querySelector(".overall");

overall.addEventListener("click", function() {
	var div = document.createElement("div");
	//	var box = parseInt(Math.random()*50+20)+"px";
	//	var show = parseInt(Math.random()*100+30)+"px";
	//	roundness.style.width = box;
	//	roundness.style.height = box;
	//	roundness.style.top = show;
	//	roundness.style.left = show;
	//	roundness.style.right = show;
	//	roundness.style.bottom = show;
	//	获取整个 overall 的 宽,高
	var clientW = overall.clientWidth;
	var clientH = overall.clientHeight;
	var divW = divH = Math.floor(Math.random() * 50 + 20);
	var divT = Math.floor(Math.random() * clientH);
	var divL = Math.floor(Math.random() * clientW);

	divT > clientH - divH ? divT = clientH - divH : divT;
	divL > clientW - divW ? divL = clientW - divW : divL;

	div.style.width = `${divW}px`;
	div.style.height = `${divH}px`;
	div.style.top = `${divT}px`;
	div.style.left = `${divL}px`;
	div.style.borderRadius = "50%";
	div.style.borderRadius = "50%";
	div.style.position = "absolute";
	div.style.backgroundColor = "#FFFFFF";
	overall.appendChild(div);
})

var firstBall = document.querySelector(".web div");
startBth.addEventListener("click", () => {
	var allBall = document.querySelectorAll(".web div");
	var newCircle = getCircle();

	function check(target) {
		allBall.forEach((e) => {
			if(bump(e, target)) {
				target.remove();
				var newCircle = getCircle();
				check(newCircle)
			}
		})
	}
	check(newCircle);
})